package com.burce.log.log4j;

import org.apache.log4j.PropertyConfigurator;

import java.io.File;

/**
 * @author xin.ding
 * @date 2020/11/17 13:58
 */
public class Log4jUtils {

    /**
     * 加载外部日志配置文件
     */
    public static void loadLog4jConfig() {
        String basePath = System.getProperty("user.dir");
        String log4jPath = basePath.concat(File.separator).concat("log4j.properties");
        String log4j2Path = basePath.concat(File.separator).concat("log4j2.xml");
        if (new File(log4jPath).exists()) {
            PropertyConfigurator.configure(log4jPath);
        }
        if (new File(log4j2Path).exists()) {
            PropertyConfigurator.configure(log4j2Path);
        }
    }
}
